<template>
  <div>
    <el-breadcrumb separator-icon="CaretRight">
      <template v-for="(item, index) in breadcrumbs" :key="index">
        <el-breadcrumb-item :to="item.path">{{ item.name }}</el-breadcrumb-item>
      </template>
    </el-breadcrumb>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { mapPathToBreadcrumbs } from '../../../untils/map-menus'
import useLoginStore from '@/store/login/login'
import { useRoute } from 'vue-router'

const route = useRoute()
const loginStore = useLoginStore()
const userMenus = loginStore.userMenus
// 计算属性处理,当我改变的时候重新计算面包屑数据
const breadcrumbs = computed(() => {
  return mapPathToBreadcrumbs(route.path, userMenus)
})
</script>

<style lang="scss" scoped></style>
